package com.dhemery.mack.adapters.tests;

import static org.junit.Assert.*;

import org.eclipse.core.runtime.IAdapterFactory;
import org.eclipse.ui.model.IWorkbenchAdapter;
import org.junit.Test;

import com.dhemery.mack.adapters.FolderInformationProvider;
import com.dhemery.mack.adapters.NodeAdapterFactory;
import com.dhemery.mack.adapters.NodeInformationProvider;
import com.dhemery.mack.model.Folder;
import com.dhemery.mack.model.Node;
import com.dhemery.mack.model.Page;
import com.dhemery.mack.model.Project;
import com.dhemery.mack.model.Session;

public class NodeAdapterFactoryIWorkbenchAdapterTests {
	
	@Test
	public void adaptsPageToNodeInformationProvider() {
		IAdapterFactory factory = new NodeAdapterFactory(null);
		Page page = new Page();
		Object adapter = factory.getAdapter(page, IWorkbenchAdapter.class);
		assertEquals(NodeInformationProvider.class, adapter.getClass());
	}

	@Test
	public void adaptsFolderToFolderInformationProvider() {
		IAdapterFactory factory = new NodeAdapterFactory(null);
		Folder folder = new Folder();
		Object adapter = factory.getAdapter(folder, IWorkbenchAdapter.class);
		assertEquals(FolderInformationProvider.class, adapter.getClass());
	}

	@Test
	public void adaptsProjectToFolderInformationProvider() {
		IAdapterFactory factory = new NodeAdapterFactory(null);
		Project project = new Project();
		Object adapter = factory.getAdapter(project, IWorkbenchAdapter.class);
		assertEquals(FolderInformationProvider.class, adapter.getClass());
	}

	@Test
	public void adaptsSessionToFolderInformationProvider() {
		IAdapterFactory factory = new NodeAdapterFactory(null);
		Session session = new Session();
		Object adapter = factory.getAdapter(session, IWorkbenchAdapter.class);
		assertEquals(FolderInformationProvider.class, adapter.getClass());
	}

	@Test
	public void doesNotAdaptNode() {
		IAdapterFactory factory = new NodeAdapterFactory(null);
		Node node = new Node(null);
		assertNull(factory.getAdapter(node, IWorkbenchAdapter.class));
	}
}
